package com.qd.common.panda.domain.entity.wallet.user;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cdqidi.dict.annotation.FieldBind;
import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.qd.common.dict.DictConstant;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

/**
 * 用户退款申请
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class UserWalletRefundApplyDTO extends BaseQuery {
    @ExcelIgnore
    @JsonIgnore
    private static final String EXCEL_TITLE = "钱包退款";

    /**
     * 主键
     */
    @NotBlank(message = "申请ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "申请ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String requestId;
    /**
     * 申请退款金额
     */
    @ExcelProperty(value = {EXCEL_TITLE,"申请退款支付金额"})
    private BigDecimal requestRefundAmount;
    /**
     * 申请退款赠送金额
     */
    @ExcelProperty(value = {EXCEL_TITLE,"申请退款赠送金额"})
    private BigDecimal requestRefundGiveAmount;
    /**
     * 实际退款金额
     */
    @ExcelProperty(value = {EXCEL_TITLE,"实际退款支付金额"})
    private BigDecimal actualRefundAmount;
    /**
     * 实际退款赠送金额
     */
    @ExcelProperty(value = {EXCEL_TITLE,"实际退款赠送金额"})
    private BigDecimal actualRefundGiveAmount;
    /**
     * 申请时间
     */
    @ExcelProperty(value = {EXCEL_TITLE,"申请时间"})
    private LocalDateTime requestTime;
    /**
     * 申请人手机号
     */
    @ExcelProperty(value = {EXCEL_TITLE,"申请人手机号"})
    @Size(max = 20, message = "申请人手机号长度不能超过{max}位", groups = DefaultGroup.class)
    private String requestMobile;
    /**
     * 退款方式:1原路退回2线下处理
     */
    @ExcelIgnore
    @FieldBind(targetField = "refundMethodDisplay", processName = DictConstant.REFUND_METHOD)
    private Integer refundMethod;
    /**
     * 退款方式显示
     */
    @ExcelProperty(value = {EXCEL_TITLE,"退款方式"})
    private String refundMethodDisplay;
    /**
     * 开户行
     */
    @ExcelProperty(value = {EXCEL_TITLE,"开户行"})
    @Size(max = 100, message = "开户行长度不能超过{max}位", groups = DefaultGroup.class)
    private String openBank;
    /**
     * 银行卡号
     */
    @ExcelProperty(value = {EXCEL_TITLE,"银行卡号"})
    @Size(max = 20, message = "银行卡号长度不能超过{max}位", groups = DefaultGroup.class)
    private String bankCard;
    /**
     * 审批状态:0审核中1审核通过2审核未通过3驳回
     */
    @ExcelIgnore
    @FieldBind(targetField = "approvalStatusDisplay", processName = DictConstant.APPROVAL_STATUS)
    private Integer approvalStatus;
    /**
     * 审批状态，批量
     */
    @ExcelIgnore
    private Object[] approvalStatusArray;
    /**
     * 审批状态显示
     */
    @ExcelProperty(value = {EXCEL_TITLE,"审批状态"})
    private String approvalStatusDisplay;
    /**
     * 完成时间
     */
    @ExcelProperty(value = {EXCEL_TITLE,"完成时间"})
    private LocalDateTime completionTime;
    /**
     * 申请人
     */
    @ExcelIgnore
    @Size(max = 50, message = "申请人长度不能超过{max}位", groups = DefaultGroup.class)
    private String applicant;
    /**
     * 退款订单
     */
    @ExcelIgnore
    private List<UserWalletRefundApplyOrderDTO> orderList;
    /**
     * 退款凭证
     */
    @ExcelIgnore
    private List<UserWalletRefundApplyFileDTO> fileList;
    /**
     * 审批日志
     */
    @ExcelIgnore
    private ObjectNode lastFlowHis;
    @Override
    public void freeData() {
        this.requestId = null;
        this.requestRefundAmount = null;
        this.requestRefundGiveAmount = null;
        this.actualRefundAmount = null;
        this.actualRefundGiveAmount = null;
        this.requestTime = null;
        this.requestMobile = null;
        this.refundMethod = null;
        this.refundMethodDisplay = null;
        this.openBank = null;
        this.bankCard = null;
        this.approvalStatus = null;
        this.approvalStatusDisplay = null;
        this.completionTime = null;
        this.applicant = null;
        this.lastFlowHis = null;
        this.approvalStatusArray = null;
        Optional.ofNullable(orderList).ifPresent(List::clear);
        Optional.ofNullable(fileList).ifPresent(List::clear);
        super.freeData();
    }
}
